package com.hsc.yalebao.base;

import android.annotation.TargetApi;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;

import com.hsc.pcddfivepcdd.R;
import com.hsc.yalebao.http.RequestNet;
import com.hsc.yalebao.tools.SharedPreferencesUtil;
import com.hsc.yalebao.tools.SystemHelper;
import com.hsc.yalebao.tools.UiUtil;
import com.hsc.yalebao.weight.DownwireDialog;
import com.hsc.yalebao.weight.LogUtils;
import com.hsc.yalebao.weight.MyDialog1;
import com.hsc.yalebao.weight.MyLoadingDialog;
import com.hsc.yalebao.weight.SwipeBackLayout;

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class BaseActivity extends FragmentActivity {
    public static ActivityStack activityStack;
    private static SharedPreferencesUtil spUtil;
    private String TAG = "BaseActivity";
    protected SwipeBackLayout contentView;
    private Context context;
    Runnable dialogDismissRunnable = new Runnable() {
        public void run() {
            if ((BaseActivity.this.myDialog1 != null) && (BaseActivity.this.myDialog1.isShowing()) && (!BaseActivity.this.isFinishing()))
                BaseActivity.this.myDialog1.dismiss();
        }
    };
    Runnable downWireDismissRunnable = new Runnable() {
        public void run() {
            if ((BaseActivity.this.downwireDialog != null) && (BaseActivity.this.downwireDialog.isShowing()) && (!BaseActivity.this.isFinishing()))
                BaseActivity.this.downwireDialog.dismiss();
        }
    };
    Runnable downWireShowRunnable = new Runnable() {
        public void run() {
            if ((BaseActivity.this.downwireDialog != null) && (!BaseActivity.this.downwireDialog.isShowing()) && (!BaseActivity.this.isFinishing()))
                BaseActivity.this.downwireDialog.show();
        }
    };
    private DownwireDialog downwireDialog;
    public List<Fragment> listFragment;
    private MyLoadingDialog loadingDialog;
    Runnable loadingDismissRunnable = new Runnable() {
        public void run() {
            if ((BaseActivity.this.loadingDialog != null) && (BaseActivity.this.loadingDialog.isShowing()) && (!BaseActivity.this.isFinishing()))
                BaseActivity.this.loadingDialog.dismiss();
        }
    };
    Runnable loadingShowRunnable = new Runnable() {
        public void run() {
            if ((BaseActivity.this.loadingDialog != null) && (!BaseActivity.this.loadingDialog.isShowing()) && (!BaseActivity.this.isFinishing()))
                BaseActivity.this.loadingDialog.show();
        }
    };
    private AlertDialog logoutDialog;
    private Handler mHandler = new Handler() {
        public void handleMessage(Message paramAnonymousMessage) {
            switch (paramAnonymousMessage.what) {
                default:
                    return;
                case 0:
                    BaseActivity.this.runOnUiThread(BaseActivity.this.loadingShowRunnable);
                    return;
                case 1:
                    BaseActivity.this.runOnUiThread(BaseActivity.this.loadingDismissRunnable);
                    return;
                case 2:
                    BaseActivity.this.runOnUiThread(BaseActivity.this.downWireShowRunnable);
                    return;
                case 3:
            }
            BaseActivity.this.runOnUiThread(BaseActivity.this.downWireDismissRunnable);
        }
    };
    private MyDialog1 myDialog1;
    private MyReceiver receiverNet = null;


    private void registerNetReceiver() {
        this.receiverNet = new MyReceiver();
        IntentFilter localIntentFilter = new IntentFilter();
        localIntentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
        localIntentFilter.setPriority(1000);
        registerReceiver(this.receiverNet, localIntentFilter);
        System.out.println("【网络监听】广播已经注册");
    }

    protected void ShowDialog1(String paramString) {
        try {
            if (isFinishing())
                return;
            this.myDialog1.show();
            this.myDialog1.setMessage(paramString);
            this.myDialog1.btn_confirm.setOnClickListener(new View.OnClickListener() {
                public void onClick(View paramAnonymousView) {
                    if (!BaseActivity.this.isFinishing())
                        BaseActivity.this.myDialog1.dismiss();
                }
            });
            return;
        } catch (Exception localException) {
            LogUtils.e(this.TAG, localException.getMessage());
        }
    }

    protected void ShowFengjinDialog() {
        this.myDialog1.show();
        this.myDialog1.setMessage("您的账号已被封禁");
        this.myDialog1.btn_confirm.setOnClickListener(new View.OnClickListener() {
            public void onClick(View paramAnonymousView) {
                if (!BaseActivity.this.isFinishing())
                    BaseActivity.this.myDialog1.dismiss();
                CustomApplication.app.finishAllActivity();
                Intent localIntent = new Intent(BaseActivity.this.context, MainActivity.class);
                MainActivity.mainActivity.performClickBtn(0);
                ((Activity) BaseActivity.this.context).startActivity(localIntent);
                CustomApplication.app.isLogin = false;
                CustomApplication.app.userBaseBean = null;
                RequestNet.accessToken = "";
            }
        });
    }

    protected void closeWindowSoftInput(View paramView) {
        LogUtils.i(this.TAG, "closeWindowSoftInput");
        InputMethodManager localInputMethodManager = (InputMethodManager) getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        if ((localInputMethodManager.isActive()) && (paramView != null) && (paramView.getWindowToken() != null)) {
            localInputMethodManager.hideSoftInputFromWindow(paramView.getWindowToken(), 0);
            LogUtils.d(this.TAG, "强制隐藏键盘");
        }
    }


    public void dismissLoadingDialog() {
        runOnUiThread(this.loadingDismissRunnable);
    }


    public void navigateToNoAnimWithId(Fragment paramFragment, int paramInt) {
        FragmentTransaction localFragmentTransaction = getSupportFragmentManager().beginTransaction();
        localFragmentTransaction.add(paramInt, paramFragment);
        localFragmentTransaction.addToBackStack(null);
        localFragmentTransaction.commitAllowingStateLoss();
    }

    public void onBackPressed() {
        super.onBackPressed();
        if (this.listFragment.size() > 1) {
            Fragment localFragment = (Fragment) this.listFragment.get(-2 + this.listFragment.size());
            getSupportFragmentManager().beginTransaction().show(localFragment).commit();
            this.listFragment.remove(-1 + this.listFragment.size());
        }
        while (true) {
            finish();
            return;

        }
    }

    @TargetApi(19)
    protected void onCreate(Bundle paramBundle) {
        super.onCreate(paramBundle);
        this.context = this;
        requestWindowFeature(1);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        if (Build.VERSION.SDK_INT >= 19)
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
        this.contentView = ((SwipeBackLayout) LayoutInflater.from(this).inflate(R.layout.base, null));
        this.contentView.attachToActivity(this);
        this.listFragment = new ArrayList();
        spUtil = SharedPreferencesUtil.getInstance(this);
        registerNetReceiver();
        this.loadingDialog = new MyLoadingDialog(this.context);
        this.downwireDialog = new DownwireDialog(this.context);
        this.downwireDialog.setCancelable(false);
        this.myDialog1 = new MyDialog1(this.context);
        activityStack = ActivityStack.getInstance();
        activityStack.pushActivity(this);
    }

    public View onCreateView(String paramString, Context paramContext, AttributeSet paramAttributeSet) {
        return super.onCreateView(paramString, paramContext, paramAttributeSet);
    }

    protected void onDestroy() {
        super.onDestroy();
        RequestNet.cancelTag(this.context);
        if (this.receiverNet != null)
            unregisterReceiver(this.receiverNet);
        while (true) {
            closeWindowSoftInput(getCurrentFocus());
            overridePendingTransition(0, 2130968581);
            runOnUiThread(this.loadingDismissRunnable);
            runOnUiThread(this.downWireDismissRunnable);
            runOnUiThread(this.dialogDismissRunnable);
            LogUtils.d(this.TAG, "onDestroy()");
            CustomApplication.app.finishActivity(this);
            return;
        }
    }

    protected void onResume() {
        super.onResume();
    }

    protected void showDownWireDialog() {
        runOnUiThread(this.downWireShowRunnable);
    }

    public void showLoadingDialog() {
        runOnUiThread(this.loadingShowRunnable);
    }

    public void startActivity(Intent paramIntent) {
        super.startActivity(paramIntent);
    }

    public class MyReceiver extends BroadcastReceiver {
        public MyReceiver() {
        }

        public void onReceive(Context paramContext, Intent paramIntent) {
            if (paramIntent.getAction().equals("android.net.conn.CONNECTIVITY_CHANGE")) {
                if ((SystemHelper.isConnected(BaseActivity.this)) && (SystemHelper.getNetworkType(BaseActivity.this) != -1)) {
                    CustomApplication.app.isNetConnect = true;
                    SystemHelper.getNetworkType(BaseActivity.this.getApplicationContext());
                    SystemHelper.getNetworkType(BaseActivity.this.getApplicationContext());
                }
            } else
                return;
            CustomApplication.app.isNetConnect = false;
            UiUtil.showToast(BaseActivity.this.getApplicationContext(), "哎呦,网络开小差了");
        }
    }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.hsc.yalebao.base.BaseActivity
 * JD-Core Version:    0.6.2
 */